<?php
/**
 * pay 第三方支付类
 * 提供一系列的第三方支付类方法方法
 * @author    fkfk <q996633@qq.com>
 */

class NPay {
	private $appid = '';
	private $appsecret = '';
	
	function __construct($appid, $appsecret) {
		$this->appid = $appid;
		$this->appsecret = $appsecret;
	}

	//发送信息验证
	public function sign($param) {
		$param['appid'] = $this->appid;
		$param = array_merge(['appsecret' => $this->appsecret], $param);
		ksort($param);
		$param['sign'] = md5(json_encode($param));
		unset($param['appsecret']);
		return $param;
	}

	//接收信息验证
	public function mac($param) {
		unset($param['v_mac']);
		$param['appid'] = $this->appid;
		$param['appsecret'] = $this->appsecret;
		ksort($param);
		$mac = md5(json_encode($param));
		return $mac;
	}

}//类定义结束